package com 
{
	import com.mathMl.MathPanel;
	import com.mathMl.MathPanelEvent;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.LoaderInfo;
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import fmath.MathML;
	
	/**
	 * ...
	 * @author Mohan Patil
	 */
	public class AdvTextBox extends MovieClip 
	{
		//private var txtData:TextField;
		private var underScoreWidth:Number;
		private var placeHolderTypes:Array = new Array();
		private var placeHolderData:Array = new Array();
		private var blankChar:String = "_";
		private var _placeHolderObjects:Array = new Array();
		private var textData:String;
		private var textFormat:TextFormat;
		private var textBoxWidth:Number;
		private var placeHolderObjs:Array;
		private var _placeHolderColorForHiding:uint;
		private var _monitorValueChange:Boolean = true;
		var places:Array = new Array();
		private var flag:Boolean = true;
		private var _monitorBackgroundColor:Boolean;
		private var _rendered:Boolean = false;
		//private var txtTemp:TextField = new TextField();
		
		
		public function get placeHolderObjects():Array 
		{
			return _placeHolderObjects;
		}
		
		public function set placeHolderObjects(value:Array):void 
		{
			_placeHolderObjects = value;
		}
		
		public function get monitorValueChange():Boolean 
		{
			return _monitorValueChange;
		}
		
		public function set monitorValueChange(value:Boolean):void 
		{
			_monitorValueChange = value;
			if (_monitorValueChange)
			{
				this.addEventListener(Event.ENTER_FRAME, this_EnterFrame);
			}
			else
			{
				if (this.hasEventListener(Event.ENTER_FRAME))
				{
					this.removeEventListener(Event.ENTER_FRAME, this_EnterFrame);
				}
			}
		}
		
		public function get rendered():Boolean 
		{
			return _rendered;
		}
		
		public function set rendered(value:Boolean):void 
		{
			_rendered = value;
		}
		
		public function AdvTextBox(textData:String, textFormat:TextFormat, textBoxWidth:Number, placeHolderColorForHiding:uint = 0xFFFFFF, monitorBackgroundColor:Boolean = true)//, loaderInfoObj:LoaderInfo, ...placeHolderObjs
		{
			MathML.setUrlFonts("fontswf");
			this.placeHolderObjs = placeHolderObjs;
			this.textBoxWidth = textBoxWidth;
			this.textFormat = textFormat;
			this.textData = textData;
			_placeHolderColorForHiding = placeHolderColorForHiding;
			_monitorBackgroundColor = monitorBackgroundColor;
			//trace("AdvTextBox : constructor called");
			//trace("AdvTextBox : textData : " + textData);
			//trace("AdvTextBox : textFormat : " + textFormat);
			//trace("AdvTextBox : textBoxWidth : " + textBoxWidth);
		}
			
		public function createObject()
		{
			this.addEventListener(Event.ADDED_TO_STAGE, this_AddedToStage);
			
			//txtData.htmlText = textData;
			//txtData = new TextField();
			txtData.type = TextFieldType.DYNAMIC;
			txtData.width = textBoxWidth;
			txtData.selectable = false;
			//txtData.border = true;
			txtData.multiline = true;
			txtData.wordWrap = true;
			txtData.autoSize = TextFieldAutoSize.LEFT;
			txtData.antiAliasType = AntiAliasType.ADVANCED;
			txtData.embedFonts = true;
			
			txtTemp.type = TextFieldType.DYNAMIC;
			txtTemp.width = textBoxWidth;
			txtTemp.selectable = false;
			//txtTemp.border = true;
			txtTemp.multiline = true;
			txtTemp.wordWrap = true;
			txtTemp.autoSize = TextFieldAutoSize.LEFT;
			txtTemp.antiAliasType = AntiAliasType.ADVANCED;
			txtTemp.embedFonts = true;
			
			txtTemp.visible = false;
			
			textFormat = txtData.getTextFormat();
			
			/*var txtFormat:TextFormat = new TextFormat();
			txtFormat.size = fontSize;
			txtFormat.font = fontFamily;
			txtFormat.leading = 10;*/
			//txtData.x = 2;
			//txtData.y = 2;
			//this.addChild(txtData);
			//trace(txtData.getCharBoundaries(0));
			//underScoreWidth = txtData.getCharBoundaries(0).width;
			//trace("underScoreWidth : " + underScoreWidth);
			
			//trace(placeHolderObjs);
			//_placeHolderObjects = placeHolderObjs;
			var str:String = textData;
			//var pattern1:RegExp = /\{\w[\]\[!"#$%&'()*+,.\/:;<=>?@\^_`{|}~-]*\}/;
			var pattern1:RegExp = /\{(.*?)\}/;
			//var pattern2:RegExp = /_.*?:_/g;
			var pattern2:RegExp = /_*_/g;
			var obj:Object;
			
			//trace(str.match(pattern));
			//trace("str: " +  str);
			//trace("String length : " + str.length);
			
			
			do
			{
				obj = pattern1.exec(str);
				//trace("obj : " + obj);
				if (obj != null)
				{
					//trace("String " + String(obj[0]) + " found from " + obj.index + " to " + pattern1.lastIndex);
					var stringToReplace:String = String(obj[0]);
					var data:String = String(obj[1]);
					//var typePart:String = stringToReplace.split("_")[0];
					//var numberPart:String = stringToReplace.split("_")[1];
					//var dataPart:String = stringToReplace.split("_")[2];
					//trace("typePart: " + typePart);
					//trace("dataPart: " + dataPart);
					//placeHolderTypes.push(typePart.substring(1));
					//placeHolderData.push(dataPart.substr(0, dataPart.length - 1));
					placeHolderData.push(data);
					var typePart:String = data.split("_")[0];
					var numberPart:Number = data.split("_")[1];
					var dataPart:String = "";
					var optionsPart:String = "";
					try
					{
						if (data.split("_")[2] == null)
						{
							dataPart = "";
						}
						else
						{
							dataPart = data.split("_")[2];
						}
						
					}
					catch(er:Error)
					{
						dataPart = "";
					}
					try
					{
						if (data.split("_")[3] == null)
						{
							optionsPart = "";
						}
						else
						{
							optionsPart = data.split("_")[3];
						}
						
					}
					catch(er:Error)
					{
						optionsPart = "";
					}
					//trace("typePart : " + typePart);
					//trace("numberPart : " + numberPart);
					//trace("dataPart : " + dataPart);
					//trace("optionsPart : " + optionsPart);
					_placeHolderObjects.push(new PlaceHolderItem(typePart, numberPart, dataPart, optionsPart));
					//var noOfChars:Number = Number(numberPart.substring(0, numberPart.length - 1));
					
					var replacementString:String = "";
					for (var j = 0; j < numberPart; j++)
					{
						replacementString += "_";
					}
					//trace("replacementString : " +  replacementString);
					str = str.replace(stringToReplace, replacementString);
				}
				else
				{
					//trace("obj is null");
					break;
				}
			}
			while (pattern1.exec(str) != null);
			
			//trace("str: " +  str);
			
			txtData.htmlText = str;
			//txtData.setTextFormat(textFormat);
			
			/*for (i = 0; i < txtData.numLines; i++)
			{
				trace(txtData.getLineText(i));
				trace(txtData.getLineMetrics(i).leading);
			}*/
			
			if (_placeHolderObjects.length > 0)
			{
				while (pattern2.lastIndex < txtData.text.toString().length - 1)
				{
					obj = pattern2.exec(txtData.text.toString());
					//trace(obj);
					if (obj != null)
					{
						//trace("String " + String(obj) + " found from " + obj.index + " to " + pattern2.lastIndex);
						//trace("Data in string : " + str.substring(obj.index, pattern2.lastIndex));
						if (txtData.text.charAt(obj.index - 1) != "?")
						{
							places.push(obj.index + "," + String(pattern2.lastIndex - 1));
						}
						else
						{
							txtData.replaceText(obj.index - 1, obj.index, "_");
						}
					}
					else
					{
						break;
					}
				}
			}
			
			//trace(places);
			
			if (places.length > 0)
			{
				var txtFormat_White:TextFormat = new TextFormat();
				txtFormat_White.size = textFormat.size;
				//txtFormat_White.font = fontFamily;
				txtFormat_White.font = textFormat.font;
				txtFormat_White.color = _placeHolderColorForHiding;
				//txtData.setTextFormat(txtFormat);
				
				for (var i = 0; i < places.length; i++)
				{
					var em_space_str:String = "";
					for (var a = 0; a <= Number(places[i].split(",")[1]) - Number(places[i].split(",")[0]); a++)
					{
						//em_space_str += String.fromCharCode(8195);
						em_space_str += "  ";
					}
					//trace("em_space_str : " + em_space_str + "WWW");
					//trace("char before _ " + txtData.text.charAt(Number(places[i].split(",")[0]) - 1));
					txtData.setTextFormat(txtFormat_White, Number(places[i].split(",")[0]), Number(places[i].split(",")[1]) + 1);
					//txtData.replaceText(Number(places[i].split(",")[0]), Number(places[i].split(",")[1]) + 1, em_space_str);
					//trace(txtData.getCharBoundaries(46));
					
					var line1:Number = txtData.getLineIndexOfChar(Number(places[i].split(",")[0]));
					var line2:Number = txtData.getLineIndexOfChar(Number(places[i].split(",")[1]));
					//trace("line1 : " + line1 + ", line2 : " + line2);
					
					var line1StartIndex:Number = txtData.getLineOffset(line1);
					//trace("line1StartIndex : " + line1StartIndex);
					var charOffset1:Number = Number(places[i].split(",")[0]) - line1StartIndex;
					//trace("charOffset1 = " + charOffset1);
					var charOffset2:Number = Number(places[i].split(",")[1]) - line1StartIndex;
					//trace("charOffset2 = " + charOffset2);
					
					txtTemp.htmlText = txtData.getLineText(line1);
					//txtTemp.setTextFormat(textFormat);
					var tempRect1:Rectangle = txtTemp.getCharBoundaries(charOffset1);
					var tempRect2:Rectangle = txtTemp.getCharBoundaries(charOffset2);
					//trace("tempRect1 : " + tempRect1.toString());
					//trace("tempRect2 : " + tempRect2.toString());
					
					var line1Y:Number = 2;
					for (j = 0; j < line1; j++)
					{
						line1Y += txtData.getLineMetrics(j).height;
					}
					//trace("line1Y : " + line1Y);
					
					var line2Y:Number = 2;
					for (j = 0; j < line2; j++)
					{
						line2Y += txtData.getLineMetrics(j).height;
					}
					//trace("line2Y : " + line2Y);
					
					var rect1:Rectangle = new Rectangle(tempRect1.x, line1Y, tempRect1.width, tempRect1.height);
					var rect2:Rectangle = new Rectangle(tempRect2.x, line2Y, tempRect2.width, tempRect2.height);
					
					//var rect1:Rectangle = txtData.getCharBoundaries(Number(places[i].split(",")[0]));
					//var rect1:Rectangle = txtData.getCharBoundaries(46);
					//var rect2:Rectangle = txtData.getCharBoundaries(Number(places[i].split(",")[1]));
					//trace("rect1 : " + rect1.toString());
					//trace("rect2 : " + rect2.toString());
					//trace("AdvTextBox : PlaceHolderItem(_placeHolderObjects[i]).type : " + PlaceHolderItem(_placeHolderObjects[i]).type);
					switch(PlaceHolderItem(_placeHolderObjects[i]).type)
					{
						case "B":
						{
							var mc:BlankSpace = new BlankSpace();
							mc.x = txtData.x + rect1.x;
							mc.y = txtData.y + rect1.y - (Number(textFormat.size) * 2 / 14);
							mc.txt.setTextFormat(textFormat);
							mc.txt.multiline = false;
							mc.txt.text = "";
							mc.correctValue = String(PlaceHolderItem(_placeHolderObjects[i]).options.split("|")[0]);
							mc.addEventListener(BlankSpaceEvent.TEXT_CHANGED, blankSpace_textChanged);
							//mc.txt.autoSize = TextFieldAutoSize.CENTER;
							mc.txt.width = rect2.x - rect1.x + rect2.width - 4;
							mc.mcBg.width = rect2.x - rect1.x + rect2.width
							mc.mcBg.height = mc.txt.height + 4;
							//mc.mcBg.height = rect1.height;
							//mc.txt.height = rect1.height;
							mc.name = "mcBlank_" + i;
							PlaceHolderItem(_placeHolderObjects[i]).object = MovieClip(mc);
							this.addChild(mc);
							PlaceHolderItem(_placeHolderObjects[i]).rendered = true;
							checkAllRendered();
							break;
						}
						case "M":
						{
							var formula:MathPanel = new MathPanel();
							//trace("rect1 : " + rect1);
							formula.x = txtData.x + rect1.x;
							formula.y = txtData.y + rect1.y + rect1.height / 2;
							formula.name = "mcFormula_" + i;
							formula.addEventListener(MathPanelEvent.ON_FORMULA_ADDED, onFomulaAdded);
							formula.drawFormula(PlaceHolderItem(_placeHolderObjects[i]).data, Number(textFormat.size));
							PlaceHolderItem(_placeHolderObjects[i]).object = formula;
							this.addChild(formula);
							break;
						}
						case "I":
						{
							var mcImage:Image = new Image(PlaceHolderItem(_placeHolderObjects[i]).data);
							mcImage.x = txtData.x + rect1.x;
							mcImage.y = txtData.y + rect1.y - (Number(textFormat.size) * 2 / 14);
							mcImage.name = "mcImage_" + i;
							mcImage.addEventListener(Event.COMPLETE, mcImageLoadComplete);
							PlaceHolderItem(_placeHolderObjects[i]).object = MovieClip(mcImage);
							this.addChild(mcImage);
							break;
						}
						case "O":
						{
							break;
						}
						case "D":
						{
							var advDdCorrectItemId:Number = Number(PlaceHolderItem(_placeHolderObjects[i]).options.split("|")[0]);
							var advDdShuffle:Boolean = Boolean(Number(PlaceHolderItem(_placeHolderObjects[i]).options.split("|")[1]));
							var advDd:AdvDropDown = new AdvDropDown(textFormat, (rect2.x - rect1.x + rect2.width), advDdShuffle);
							//trace("DropDown Data : " + PlaceHolderItem(_placeHolderObjects[i]).data);
							var arrDdItems:Array = PlaceHolderItem(_placeHolderObjects[i]).data.split("|");
							for (j = 0; j < arrDdItems.length; j++)
							{
								var itemType:String = "";
								//trace(String(arrDdItems[j]).substring(0, 1));
								switch(String(arrDdItems[j]).substring(0, 1))
								{
									case "T":
									{
										itemType = "text";
										break;
									}
									case "M":
									{
										itemType = "math";
										break;
									}
									case "I":
									{
										itemType = "image";
										break;
									}
									default:
									{
										itemType = "text";
										break;
									}
								}
								advDd.addItem(new AdvDropDownItem(j, itemType, String(arrDdItems[j]).substring(2)));
							}
							advDd.correctItemId = advDdCorrectItemId;
							advDd.createItems();
							//advDd.addItem(new AdvDropDownItem(0,
							//var advDd:AdvDropDown = AdvDropDown(placeHolderObjs[i]);
							advDd.x = txtData.x + rect1.x;
							advDd.y = txtData.y + rect1.y + rect1.height / 2;
							advDd.addEventListener(AdvDropDownEvent.SELECTION_CHANGED, advDd_SelectionChanged);
							advDd.name = "mcAdvDropDown_" + i;
							advDd.addEventListener(AdvDropDownEvent.DRAW_COMPLETE, advDdDrawComplete);
							advDd.addEventListener(AdvDropDownEvent.ITEM_LIST_SHOWN, advDdItemListShown);
							PlaceHolderItem(_placeHolderObjects[i]).object = advDd;
							this.addChild(advDd);
							break;
						}
					}
					//txtData.replaceText(Number(places[i].split(",")[0]), Number(places[i].split(",")[1]) + 1, em_space_str);
				}
			}
			else
			{
				_rendered = true;
				this.dispatchEvent(new AdvTextBoxEvent(AdvTextBoxEvent.RENDER_COMPLETE, true, false));
			}
		}
		
		private function this_AddedToStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, this_AddedToStage);
			if (_monitorBackgroundColor)
			{
				this.addEventListener(Event.ENTER_FRAME, this_EnterFrame);
			}
		}
		
		private function this_EnterFrame(e:Event):void 
		{
			//trace("Enterframe called" + _placeHolderColorForHiding.toString(16));
			var i;
			
			try
			{
				if (this.parent != null)
				{
					var bd:BitmapData = new BitmapData(this.parent.width, this.parent.height, false);
					bd.draw(this.parent);
					var b:Bitmap = new Bitmap(bd);
					var newColor:uint = b.bitmapData.getPixel(this.x + 2, this.y + 2);
					_placeHolderColorForHiding = newColor;
					var placeHolderTxtFormat:TextFormat = new TextFormat();
					placeHolderTxtFormat.color = newColor;
						
					for (i = 0; i < places.length; i++)
					{
						txtData.setTextFormat(placeHolderTxtFormat, Number(places[i].split(",")[0]), Number(places[i].split(",")[1]) + 1);
					}
				}
			}
			catch (er:Error)
			{
				
			}
		}
		
		public function changePlaceHolderColorForHiding(newColor:uint)
		{
			var i;
			_placeHolderColorForHiding = newColor;
			var placeHolderTxtFormat:TextFormat = new TextFormat();
			placeHolderTxtFormat.color = newColor;
				
			for (i = 0; i < places.length; i++)
			{
				txtData.setTextFormat(placeHolderTxtFormat, Number(places[i].split(",")[0]), Number(places[i].split(",")[1]) + 1);
			}
		}
		
		private function advDdItemListShown(e:AdvDropDownEvent):void 
		{
			try
			{
				this.parent.setChildIndex(this, this.parent.numChildren - 1);
			}
			catch(er:Error)
			{
				
			}
		}
		
		private function checkAllRendered():void 
		{
			var i:Number;
			var allRendered:Boolean = true;
			for (i = 0; i < _placeHolderObjects.length; i++)
			{
				if (PlaceHolderItem(_placeHolderObjects[i]).rendered == false)
				{
					allRendered = false;
				}
			}
			//Tracer.traceMsg("AdvTextBox : allRendered : " + allRendered);
			//Tracer.traceMsg("txtData.textHeight : " + txtData.textHeight);
			//Tracer.traceMsg("this.height : " + this.height);
			if (allRendered)
			{
				//trace("AdvTextBox : Dispatching AdvTextBoxEvent.RENDER_COMPLETE event");
				_rendered = true;
				this.dispatchEvent(new AdvTextBoxEvent(AdvTextBoxEvent.RENDER_COMPLETE, true, false));
				//trace("AdvTextBox : Dispatched AdvTextBoxEvent.RENDER_COMPLETE event");
			}
		}
		
		private function advDdDrawComplete(e:AdvDropDownEvent):void 
		{
			var num:Number = Number(String(AdvDropDown(e.target).name.split("_")[1]));
			PlaceHolderItem(_placeHolderObjects[num]).rendered = true;
			checkAllRendered();
		}
		
		private function onFomulaAdded(e:MathPanelEvent):void 
		{
			//Tracer.traceMsg("MathPanel(e.target).height : " + MathPanel(e.target).height);
			//trace("AdvTextBox : onFomulaAdded called on " + MathPanel(e.target).name);
			var num:Number = Number(String(MathPanel(e.target).name.split("_")[1]));
			PlaceHolderItem(_placeHolderObjects[num]).rendered = true;
			checkAllRendered();
		}
		
		private function mcImageLoadComplete(e:Event):void 
		{
			var num:Number = Number(String(Image(e.target).name.split("_")[1]));
			PlaceHolderItem(_placeHolderObjects[num]).rendered = true;
			checkAllRendered();
		}
		
		public function checkAllCorrect():Boolean
		{
			var allCorrect:Boolean = true;
			var i:Number;
			for (i = 0; i < _placeHolderObjects.length; i++)
			{
				if (checkItemCorrect(PlaceHolderItem(_placeHolderObjects[i])) == false)
				{
					allCorrect = false;
					break;
				}
			}
			return(allCorrect);
		}
		
		private function checkItemCorrect(item:PlaceHolderItem):Boolean
		{
			var isCorrect:Boolean = true;
			switch(item.type)
			{
				case "B":
				{
					//trace("BlankSpace correct value : " + BlankSpace(item.object).correctValue);
					if (BlankSpace(item.object).correctValue == BlankSpace(item.object).textValue)
					{
						isCorrect = true;
					}
					else
					{
						isCorrect = false;
					}
					break;
				}
				case "M":
				{
					break;
				}
				case "I":
				{
					break;
				}
				case "O":
				{
					break;
				}
				case "D":
				{
					if (AdvDropDown(item.object).selectedItem != null)
					{
						//trace("AdvDropDown correct value : " + AdvDropDown(item.object).correctItemId);
						if (AdvDropDown(item.object).correctItemId == AdvDropDown(item.object).selectedItem.id)
						{
							isCorrect = true;
						}
						else
						{
							isCorrect = false;
						}
					}
					else
					{
						isCorrect = false;
					}
					break;
				}
			}
			return(isCorrect);
		}
		
		public function checkAllAttempted():Boolean
		{
			var allAttempted:Boolean = true;
			var i:Number;
			for (i = 0; i < _placeHolderObjects.length; i++)
			{
				if (checkItemAttempted(PlaceHolderItem(_placeHolderObjects[i])) == false)
				{
					allAttempted = false;
					break;
				}
			}
			return(allAttempted);
		}
		
		private function checkItemAttempted(item:PlaceHolderItem)
		{
			var isAttempted:Boolean = true;
			switch(item.type)
			{
				case "B":
				{
					//trace("BlankSpace textValue : " + BlankSpace(item.object).textValue);
					if (BlankSpace(item.object).textValue.length == 0 || BlankSpace(item.object).textValue == "")
					{
						isAttempted = false;
					}
					break;
				}
				case "M":
				{
					break;
				}
				case "I":
				{
					break;
				}
				case "O":
				{
					break;
				}
				case "D":
				{
					if (AdvDropDown(item.object).selectedItem == null)
					{
						isAttempted = false;
					}
					break;
				}
			}
			return(isAttempted);
		}
		
		public function lockAll(state:Boolean)
		{
			var i:Number;
			for (i = 0; i < _placeHolderObjects.length; i++)
			{
				var item:PlaceHolderItem = PlaceHolderItem(_placeHolderObjects[i]);
				switch(item.type)
				{
					case "B":
					{
						BlankSpace(item.object).locked = state;
						break;
					}
					case "M":
					{
						break;
					}
					case "I":
					{
						break;
					}
					case "O":
					{
						break;
					}
					case "D":
					{
						AdvDropDown(item.object).locked = state;
						break;
					}
				}
			}
		}
		
		public function showHighlights()
		{
			var i:Number;
			for (i = 0; i < _placeHolderObjects.length; i++)
			{
				var item:PlaceHolderItem = PlaceHolderItem(_placeHolderObjects[i]);
				switch(item.type)
				{
					case "B":
					{
						BlankSpace(item.object).showHighlight();
						break;
					}
					case "M":
					{
						break;
					}
					case "I":
					{
						break;
					}
					case "O":
					{
						break;
					}
					case "D":
					{
						AdvDropDown(item.object).showHighlight();
						break;
					}
				}
			}
		}
		
		public function showCorrectAnswers()
		{
			var i:Number;
			for (i = 0; i < _placeHolderObjects.length; i++)
			{
				var item:PlaceHolderItem = PlaceHolderItem(_placeHolderObjects[i]);
				switch(item.type)
				{
					case "B":
					{
						BlankSpace(item.object).showCorrectAnswer();
						break;
					}
					case "M":
					{
						break;
					}
					case "I":
					{
						break;
					}
					case "O":
					{
						break;
					}
					case "D":
					{
						AdvDropDown(item.object).showCorrectAnswer();
						break;
					}
				}
			}
		}
		
		private function blankSpace_textChanged(e:Event):void 
		{
			//trace("blankSpace_textChanged");
			var tempBlankSpace:BlankSpace = BlankSpace(e.target);
			//trace(tempBlankSpace.name);
			//trace(tempBlankSpace.textValue.length + " : " + tempBlankSpace.textValue);
			if (_monitorValueChange)
			{
				dispatchEvent(new AdvTextBoxEvent(AdvTextBoxEvent.ITEM_VALUE_CHANGED, true, false));
			}
		}
		
		private function advDd_SelectionChanged(e:AdvDropDownEvent):void 
		{
			//trace("advDd_valueChanged");
			var tempAdvDd:AdvDropDown = AdvDropDown(e.target);
			//trace(tempAdvDd.name);
			//trace(tempAdvDd.selectedItem.id);
			if(_monitorValueChange)
			{
				dispatchEvent(new AdvTextBoxEvent(AdvTextBoxEvent.ITEM_VALUE_CHANGED, true, false));
			}
		}
	}
}